package sort;

import entity.Product;

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        //simple();

        List<Product> list = new ArrayList<>();

        Product p1 = new Product(1, "ee");
        Product p2 = new Product(10, "xxx");
        Product p3 = new Product(3, "c");
        Product p4 = new Product(8, "g");
        Product p5 = new Product(30, "tttt");
        list.add(p1);
        list.add(p2);
        list.add(p3);
        list.add(p4);
        list.add(p5);

        list.sort((c1, c2) -> c1.getName().length() - c2.getName().length());
        list.forEach(System.out::println);
    }

    private static void simple() {
        List<Integer> list = new ArrayList<>();
        list.add(56);
        list.add(12);
        list.add(678);
        list.add(6);
        list.add(77);

        list.sort((i1, i2) -> i1 - i2);
        list.forEach(System.out::println);
    }
}
